package com.ruoyi.web;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;

@RestController
@RequestMapping("/test/ocr")
public class Test3 {

    public static void main(String[] args) {
        String path = "C:\\Users\\DELL\\Desktop\\test01.png";
        String data = "D:\\workspace\\idea\\new_back\\tessdata";
        File file = new File(path);
        ITesseract instance = new Tesseract();
        instance.setDatapath(data);
        instance.setLanguage("eng");

        String result = null;
        try {
            result = instance.doOCR(file);
            System.out.println(result);
            System.out.println("111111111111111111");
        } catch (TesseractException e) {
            e.printStackTrace();
        }
    }
}
